var e = require;
var t = module;
var n = exports;
("use strict");
var o,
  t =
    (this && this.__extends) ||
    ((o = function (e, t) {
      return (o =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (e, t) {
            e.__proto__ = t;
          }) ||
        function (e, t) {
          for (var n in t)
            Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
        })(e, t);
    }),
    function (e, t) {
      function n() {
        this.constructor = e;
      }
      o(e, t),
        (e.prototype =
          null === t
            ? Object.create(t)
            : ((n.prototype = t.prototype), new n()));
    }),
  i =
    (this && this.__spreadArrays) ||
    function () {
      for (var e = 0, t = 0, n = arguments.length; t < n; t++)
        e += arguments[t].length;
      for (var o = Array(e), i = 0, t = 0; t < n; t++)
        for (var r = arguments[t], y = 0, a = r.length; y < a; y++, i++)
          o[i] = r[y];
      return o;
    };
Object.defineProperty(n, "__esModule", { value: !0 }), (n.Android = void 0);
var r,
  e = e("BasePlatform"),
  y =
    window.jsb && jsb.reflection
      ? jsb.reflection.callStaticMethod
      : function () {
          for (var e = [], t = 0; t < arguments.length; t++)
            e[t] = arguments[t];
        },
  t =
    ((r = e.BasePlatform),
    t(a, r),
    (a.prototype.getInstance = function () {
      return this;
    }),
    (a.prototype.showRewardAds = function (e) {
      console.log("[platform] [AndroidPlatform] showRewardAds"),
        (window.iOSSendMsg = this.rewardCallBack),
        (this._rewardAdsCb = null),
        (this._rewardAdsCb = e),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "showVideo",
            "(Ljava/lang/String;)V",
            this._config.rewardID
          );
    }),
    (a.prototype.showBanner = function () {
      console.log("[platform] [AndroidPlatform] showBanner"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "addBanner",
            "(Ljava/lang/String;)V",
            this._config.bannerID
          );
    }),
    (a.prototype.hideBanner = function () {
      console.log("[platform] [AndroidPlatform] hideBanner"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "hideBanner",
            "()V"
          );
    }),
    (a.prototype.showNativeAdvanceBigBanner = function (e, t) {
      if ((void 0 === t && (t = !1), 0 < this.nativeAdvanceBigBannerTotal))
        return e && e();
      this.nativeAdvanceBigBannerTotal++,
        console.log("[platform] [AndroidPlatform] showNativeAdvanceBigBanner"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "showNativeAdvanceBigBanner",
            "(Z)V",
            t
          ),
        (this.nativeAdvanceBigBannerCallBack = e);
    }),
    (a.prototype.hideNativeAdvanceBigBanner = function () {
      console.log("[platform] [AndroidPlatform] hideNativeAdvanceBigBanner"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "hideNativeAdvanceBigBanner",
            "()V"
          ),
        this.nativeAdvanceBigBannerTotal--,
        this.nativeAdvanceBigBannerTotal <= 0 &&
          (this.nativeAdvanceBigBannerTotal = 0);
    }),
    (a.prototype.showInsertBannerImg = function (e, t) {
      if ((void 0 === t && (t = !1), 0 < this.nativeInsertBannerImgTotal))
        return e && e(0);
      this.nativeInsertBannerImgTotal++,
        console.log("[platform] [AndroidPlatform] showInsertBannerImg"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "showInsertBannerImg",
            "(Z)V",
            t
          ),
        (this.nativeInsertBannerImgCallBack = e);
    }),
    (a.prototype.hideInsertBannerImg = function () {
      console.log("[platform] [AndroidPlatform] hideInsertBannerImg"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "hideInsertBannerImg",
            "()V"
          ),
        this.nativeInsertBannerImgTotal--,
        this.nativeInsertBannerImgTotal <= 0 &&
          (this.nativeInsertBannerImgTotal = 0);
    }),
    (a.prototype.showInsert = function () {
      console.log("[platform] [AndroidPlatform] showInsert"),
        (window.iOSSendMsg = this.insertCallBack),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "showInsertBanner",
            "(Ljava/lang/String;)V",
            this._config.insertID
          );
    }),
    (a.prototype.showPrivacyPolicy = function () {
      console.log("[platform] [AndroidPlatform] showPrivacyPolicy"),
        window.jsb &&
          window.jsb.reflection &&
          jsb.reflection.callStaticMethod(
            "org/cocos2dx/javascript/AppActivity",
            "lookPrivacyPolicy",
            "()V"
          );
    }),
    (a.prototype.bindEvents = function () {
      var t = this;
      (window.bannerShow = function () {
        console.log("[platform] [AndroidPlatform] bannerShow");
      }),
        (window.bannerShow_err = function () {
          console.log("[platform] [AndroidPlatform] bannerShow_err");
        }),
        (window.clickBanner = function () {
          console.log("[platform] [AndroidPlatform] clickBanner");
        }),
        (window.videoUnfinish = function () {
          console.log("[platform] [AndroidPlatform] videoUnfinish"),
            setTimeout(function () {
              t._rewardAdsCb && t._rewardAdsCb(1), (t._rewardAdsCb = null);
            }, 200);
        }),
        (window.videoFinish = function () {
          console.log("[platform] [AndroidPlatform] videoFinish"),
            setTimeout(function () {
              t._rewardAdsCb && t._rewardAdsCb(0), (t._rewardAdsCb = null);
            }, 200);
        }),
        (window.videoError = function () {
          console.log("[platform] [AndroidPlatform] videoError"),
            setTimeout(function () {
              t._rewardAdsCb && t._rewardAdsCb(-1), (t._rewardAdsCb = null);
            }, 200);
        }),
        (window.insetVideoSuccess = function () {
          console.log("[platform] [AndroidPlatform] insetVideoSuccess");
        }),
        (window.rewardVideoSuccess = function () {
          console.log("[platform] [AndroidPlatform] rewardVideoSuccess");
        });
      var e = {
        onRequestPermissionsSuccess: function () {
          console.log("[platform] [AndroidPlatform] 权限获取成功");
        },
        onRequestPermissionsFail: function () {
          console.log("[platform] [AndroidPlatform] 权限获取失败");
        },
        onRequestFailAndNeverAsk: function () {
          console.log(
            "[platform] [AndroidPlatform] 权限获取失败且用户点选不再询问"
          );
        },
        onPrivacyAccept: function () {
          console.log("[platform] [AndroidPlatform] 同意隐私协议");
        },
        onPrivacyReject: function () {
          console.log("[platform] [AndroidPlatform] 拒绝隐私协议");
        },
        onRewardVideoShow: function () {
          console.log("[platform] [AndroidPlatform] 激励视频展示"),
            cc.audioEngine.pauseAll(),
            window.rewardVideoSuccess(),
            (t._isGetReward = !1);
        },
        onRewardVideoComplete: function () {
          console.log("[platform] [AndroidPlatform] 激励视频播放完成"),
            (t._isGetReward = !0);
        },
        onRewardVideoClose: function () {
          console.log(
            "[platform] [AndroidPlatform] 激励视频关闭 是否发放奖励:",
            t._isGetReward
          ),
            cc.audioEngine.resumeAll(),
            t._isGetReward
              ? setTimeout(function () {
                  window.videoFinish();
                }, 200)
              : window.videoUnfinish(),
            (t._isGetReward = !1);
        },
        onRewardVideoFail: function () {
          console.log("[platform] [AndroidPlatform] 激励视频播放失败"),
            window.videoError(),
            (t._isGetReward = !1);
        },
        onInterstitialShow: function () {
          console.log("[platform] [AndroidPlatform] 插屏展示"),
            window.insetVideoSuccess(),
            cc.audioEngine.pauseAll();
        },
        onInterstitialClose: function () {
          console.log("[platform] [AndroidPlatform] 插屏跳过"),
            cc.audioEngine.resumeAll();
        },
        onFeedRenderSuccess: function () {
          console.log("[platform] [AndroidPlatform] 信息流渲染成功");
        },
        onFeedRenderFail: function () {
          console.log("[platform] [AndroidPlatform] 信息流渲染失败");
        },
        onSplashShow: function () {
          console.log("[platform] [AndroidPlatform] onSplashShow");
        },
        onSplashClose: function () {
          console.log("[platform] [AndroidPlatform] onSplashClose");
        },
        onUnionSdkInitSuccess: function () {
          console.log("[platform] [AndroidPlatform] 聚合sdk初始化成功");
        },
        onNativeAdvanceBigBannerShow: function () {
          console.log("[platform] [AndroidPlatform] 原生大图成功展示"),
            t.nativeAdvanceBigBannerCallBack &&
              t.nativeAdvanceBigBannerCallBack(),
            (t.nativeAdvanceBigBannerCallBack = null);
        },
        onInsertBannerImgClose: function () {
          console.log("[platform] [AndroidPlatform] 插屏图片关闭展示"),
            t.nativeInsertBannerImgCallBack &&
              t.nativeInsertBannerImgCallBack(0),
            (t.nativeInsertBannerImgCallBack = null),
            t.nativeInsertBannerImgTotal--,
            t.nativeInsertBannerImgTotal <= 0 &&
              (t.nativeInsertBannerImgTotal = 0);
        },
      };
      (window.unionSdkCallback = e),
        (this.insertCallBack = function (e) {
          "adCompleted" == e
            ? (console.log("[AndroidAdCtrler][insertCallBack][adCompleted]"),
              (window.iOSSendMsg = function () {}))
            : "adSkipped" == e
            ? (console.log("[AndroidAdCtrler][insertCallBack][adSkipped]"),
              console.log("中途播放"))
            : "adsVideoFail" == e
            ? (console.log("[AndroidAdCtrler][insertCallBack][adsVideoFail]"),
              (window.iOSSendMsg = function () {}))
            : "insetVideoSuccess" == e &&
              (console.log(
                "[AndroidAdCtrler][insertCallBack][insetVideoSuccess]"
              ),
              (window.iOSSendMsg = function () {}));
        }),
        (this.rewardCallBack = function (e) {
          "adCompleted" == e
            ? (console.log(
                "[AndroidAdCtrler][rewardCallBack][videoFinish] 看完广告"
              ),
              (window.iOSSendMsg = function () {}),
              t._rewardAdsCb && t._rewardAdsCb(0),
              (t._rewardAdsCb = null),
              cc.audioEngine.resumeAll())
            : "adSkipped" == e
            ? (console.log(
                "[AndroidAdCtrler][rewardCallBack][videoUnfinish] 中途广告"
              ),
              cc.audioEngine.resumeAll(),
              (window.iOSSendMsg = function () {}),
              t._rewardAdsCb && t._rewardAdsCb(1),
              (t._rewardAdsCb = null))
            : "adsVideoFail" == e
            ? (console.log("[AndroidAdCtrler][rewardCallBack][adsVideoFail]"),
              (window.iOSSendMsg = function () {}),
              t._rewardAdsCb && t._rewardAdsCb(1),
              (t._rewardAdsCb = null),
              cc.audioEngine.resumeAll())
            : "rewardVideoSuccess" == e &&
              (console.log(
                "[AndroidAdCtrler][rewardCallBack][rewardVideoSuccess]"
              ),
              cc.audioEngine.pauseAll());
        });
    }),
    (a.prototype.report = function (e, t) {
      "number" == typeof t && (t = t.toString()),
        this.javaCall(
          "sendMsg",
          "(Ljava/lang/String;Ljava/lang/String;)V",
          e,
          t
        );
    }),
    (a.prototype.javaCall = function () {
      for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
      return y.apply(void 0, i([this.defaultClass], e));
    }),
    (a.prototype.showMoreGame = function () {
      this.javaCall("jumpLeisureSubject", "()V");
    }),
    a);
function a() {
  var e = r.call(this) || this;
  return (
    (e._rewardAdsCb = null),
    (e._isGetReward = !1),
    (e.insertCallBack = null),
    (e.rewardCallBack = null),
    (e.nativeAdvanceBigBannerCallBack = null),
    (e.nativeInsertBannerImgCallBack = null),
    (e.nativeAdvanceBigBannerTotal = 0),
    (e.nativeInsertBannerImgTotal = 0),
    (e.defaultClass = "org/cocos2dx/javascript/AppActivity"),
    console.log("安卓"),
    e.bindEvents(),
    e
  );
}
n.Android = t;
